home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / DesktopDoubler / Common / Sources / DSNubInterface.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-06-23  |  1.8 KB  |  55 lines  |  [TEXT/CWIE]

  1. #define DISABLE_LOCAL_CALLTRACE        1        // Set to 1 to disable Call Traces for this file.
  2. #define DISABLE_LOCAL_DEBUG            0        // Set to 1 to disable all debugging for this file.
  3. #include "DebugUtils.h"
  4.  
  5. #include <Gestalt.h>
  6. #include <stdio.h>
  7. #include "DSNubInterface.h"
  8. #include "Notice.h"
  9. #include "Version.h"
  10.  
  11.  
  12.  
  13.  
  14.  
  15. DeviceShareNubInfo *GetDSNubInfo(void)
  16. {
  17.     DeviceShareNubInfo    *info = NULL;
  18.     OSStatus            err;
  19.     
  20.     
  21.     // Get DeviceShareNubInfo pointer from Gestalt.
  22.     err = Gestalt(kDeviceShareSelector,(long*)&info);
  23.     if (err != noErr)
  24.         info = NULL;
  25.     
  26.     // Check for the DeviceShareNub being installed and loaded.
  27.     if ((err != noErr) || (info == NULL) || (info->signature != kDeviceShareSignature))
  28.     {
  29.         PreflightNotice(true);
  30.         PostNotice(kAlertStopAlert,"\pThe DeviceShare Control Panel is not installed.",
  31.                     "\pThe DeviceShare Control Panel must be placed inside the Control Panels Folder" \
  32.                     "\p and loaded during startup before this Control Panel can be opened.");
  33.         ExitToShell();
  34.     }
  35.     
  36.     // Check for the DeviceShareNub being a compatible version.  Since the nub and the
  37.     // app are bundled in the same file we require that their versions match exactly.
  38.     if ((kDeviceShareCompatible != *(UInt32*)&info->compatible) || (kDeviceShareVersion != *(UInt32*)&info->version))
  39.     {
  40.         Str255    msg;
  41.         char    nubVers[32],ourVers[32];
  42.         
  43.         GetNumVersionCString(ourVers);
  44.         msg[0] = sprintf((char*)&msg[1],"The installed DeviceShare Control Panel is version %s.  This " \
  45.                         "Control Panel is version %s.  You need to open the installed Control Panel, or remove " \
  46.                         "it and install this Control Panel.",NumVersionToCString(nubVers,(NumVersion*)&info->version),ourVers);
  47.         
  48.         PreflightNotice(true);
  49.         PostNotice(kAlertStopAlert,"\pThis DeviceShare Control Panel is incompatible.",msg);
  50.         ExitToShell();
  51.     }
  52.     
  53.     return info;
  54. }
  55.